﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Housing;
using System.Data.SqlClient;

public partial class StreetCenter_ViewAdmissibility : System.Web.UI.Page
{
    Admissibility admissibility = new Admissibility();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack && Request["id"] != null)
        {
            int admid = Convert.ToInt32(Request.QueryString["id"].ToString());
            SqlDataReader dr = admissibility.GetAdmissibilityById(admid);
            if (dr.Read())
            {
                lblnoid.Text = dr[1].ToString();
                txbapplyname.Text = dr[2].ToString();
                txbaddress.Text = dr[3].ToString();
                txbreceivename.Text = dr[4].ToString();
                txbphone.Text = dr[5].ToString();
                txbdate.Text = Convert.ToDateTime(dr[6].ToString()).ToString("yyyy-MM-dd");
                txbname.Text = dr[2].ToString();
                ContentPlaceHolder cph = (ContentPlaceHolder)Master.FindControl("ContentPlaceHolder1");
                TextBox txb;
                int j=7;
                for (int i = 1; i < 37; i++)
                {
                    txb = (TextBox)cph.FindControl("TextBox"+i.ToString());
                    txb.Text = dr[j].ToString() ;
                    j++;
                }
            }
            dr.Close();
        }
    }
    protected void btnupdate_Click(object sender, EventArgs e)
    {
        ArrayList array = new ArrayList();
        array.Add(txbapplyname.Text);
        array.Add(txbaddress.Text);
        array.Add(txbreceivename.Text);
        array.Add(txbphone.Text);
        array.Add(Convert.ToDateTime(txbdate.Text));

        ContentPlaceHolder cph = ((ContentPlaceHolder)Master.FindControl("ContentPlaceHolder1"));
        TextBox txb;
        for (int j = 1; j < 37; j++)
        {
            txb = (TextBox)cph.FindControl("TextBox" + j.ToString());
            array.Add(txb.Text);
        }
        int succ = admissibility.UpdateAdmissibility(array, Convert.ToInt32(Request.QueryString["id"].ToString()));
        if (succ>0)
        {
            WebHelper.AlertAndClose("修改成功！");
        }
        else
            WebHelper.Alert("网络延时，请重新操作！");
    }
}
